View Javadoc

1   // FileDescriptor.java, created Thu Jul  4  4:50:03 2002 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.ClassLib.Common.java.io;
5   
6   import joeq.Runtime.SystemInterface;
7   
8   /***
9    * FileDescriptor
10   *
11   * @author  John Whaley <jwhaley@alum.mit.edu>
12   * @version $Id: FileDescriptor.java 1456 2004-03-09 22:01:46Z jwhaley $
13   */
14  abstract class FileDescriptor {
15      
16      int fd;
17      
18      public native boolean valid();
19      
20      public void sync() throws java.io.SyncFailedException {
21          if (!this.valid()) throw new java.io.SyncFailedException("invalid file descriptor");
22          int result = SystemInterface.file_sync(this.fd);
23          if (result != 0) throw new java.io.SyncFailedException("flush failed");
24      }
25      private static void initIDs() { }
26      
27  }